

clear all
cap log close



*Graph style
sysdir set PERSONAL "W:\ado"
set scheme kailaScheme


global dummies =  "dpl_5 dpl_4 dpl_3 dpl_2 dpl_0 dpl1 dpl2 dpl3 dpl4 dpl5"
global fe_full = "baseid time year age_time mf_year mf_time " 
global cluster = "shnro"


use "${dataout}allmatches_allyears_matchpast5", clear

merge m:1 shnro year_event using "W:\workplace\data\victim_age.dta", keepusing (age_plaintiff age_suspect)
drop if _merge==2 
drop _merge 

gen age_gap=age_suspect-age_plaintiff

sort match_id1 year_event time shnro 
bys match_id1 year_event time: gegen age_gap=max(age_gap), replace 


gen new_wp_crime=victim_sykstun_lag==defendant_sykstun_lag & defendant_sykstun_lag!=""
bys match_id1 year_event: ereplace new_wp_crime=max(new_wp_crime)
keep if new_wp_crime==1 

destring suspect_sex, replace 
destring plaintiff_sex, replace 
sort match_id1 year_event time shnro 
bys match_id1 year_event time: ereplace suspect_sex=max(suspect_sex)
bys match_id1 year_event time: ereplace plaintiff_sex=max(plaintiff_sex)

gen mf=(suspect_sex==1 & plaintiff_sex==2 ) 
gen mm=(suspect_sex==1 & plaintiff_sex==1)
gen female_victim = (plaintiff_sex==2)


gen mf_year=mf*year
gen mf_time = mf*time



sort shnro year_event time 
gen prior_earnings1=realAllEarn if time==-1 
gen prior_earnings2=realAllEarn if time==-2 
gen prior_earnings3=realAllEarn if time==-3

bysort shnro year_event: ereplace  prior_earnings1=mean( prior_earnings1)
bysort shnro year_event: ereplace  prior_earnings2=mean( prior_earnings2)
bysort shnro year_event: ereplace  prior_earnings3=mean( prior_earnings3)

egen prior_earnings=rmean (prior_earnings1 prior_earnings2 prior_earnings3)

gen share_earning=realAllEarn/prior_earnings

sum share_earning, d 
replace share_earning=10 if share_earning>10



gen baseyr=year_event

gen treat= wp_crime==1

gen age_time=age+time


gen assault =(crimecode6=="210501" | crimecode6=="210701")
replace assault=1-assault



gen treatPost= treat==1 & time>0
gen iteraction_occ=treatPost*manager_sub
gen iteraction_wagegap=treatPost*manager_sub2
gen iteraction_female=treatPost*female_victim
gen iteraction_assault=treatPost*(assault)




* Generate treatment wave indentifier for each individual
egen baseid=group(shnro baseyr)

label var iteraction_female "Female Victim x Treatment"




reghdfe employed treatPost iteraction_female if mf==1|mm==1, absorb($fe_full)  cluster($cluster)
est sto employed_inter_v_no

reghdfe employed treatPost iteraction_female iteraction_assault  if mf==1|mm==1, absorb($fe_full)  cluster($cluster)
est sto employed_inter_crime

reghdfe employed treatPost iteraction_occ iteraction_assault  if mf==1 | mm==1, absorb($fe_full) cluster($cluster)
est sto employed_inter_justocc

reghdfe employed treatPost iteraction_wagegap iteraction_assault if mf==1 |mm==1, absorb($fe_full) cluster($cluster)
est sto employed_inter_justwage

reghdfe employed treatPost iteraction_female  ///
		iteraction_occ iteraction_assault   if mf==1|mm==1, absorb($fe_full)  cluster($cluster)
est sto employed_inter_v_all1

reghdfe employed treatPost iteraction_female  ///
		iteraction_wagegap iteraction_assault   if mf==1|mm==1, absorb($fe_full)  cluster($cluster)
est sto employed_inter_v_all2

reghdfe employed treatPost iteraction_female  ///
		iteraction_occ iteraction_wagegap iteraction_assault if mf==1|mm==1, absorb($fe_full)  cluster($cluster)
est sto employed_inter_v_all



esttab employed_inter_v_no employed_inter_crime employed_inter_v_all1 employed_inter_v_all2 employed_inter_justocc employed_inter_justwage employed_inter_v_all ///
	using "${results}table_perp_interaction_power_onlyassault.tex" , replace se(4)


